package cn.lili.controller.feign.system;

import cn.lili.modules.store.client.StoreLogisticsClient;
import cn.lili.modules.store.entity.dos.StoreLogistics;
import cn.lili.modules.store.entity.dto.StoreLogisticsCustomerDTO;
import cn.lili.modules.store.entity.params.StoreLogisticsParams;
import cn.lili.modules.store.entity.vos.StoreLogisticsVO;
import cn.lili.modules.system.service.StoreLogisticsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: ftyy
 * @date: 2022-01-19 18:09
 * @description: 店铺-物流公司Feign
 */
@RestController
@RequiredArgsConstructor
public class StoreLogisticsFeignController implements StoreLogisticsClient {

    private final StoreLogisticsService storeLogisticsService;

    @Override
    public List<StoreLogisticsVO> getStoreLogistics(String storeId) {
        return storeLogisticsService.getStoreLogistics(storeId);
    }

    @Override
    public StoreLogistics getStoreLogistics(String logisticsId, String storeId) {
        LambdaQueryWrapper<StoreLogistics> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(StoreLogistics::getLogisticsId, logisticsId);
        lambdaQueryWrapper.eq(StoreLogistics::getStoreId, storeId);
        return storeLogisticsService.getOne(lambdaQueryWrapper);
    }

    @Override
    public List<StoreLogisticsVO> getStoreSelectedLogistics(String storeId) {
        return storeLogisticsService.getStoreSelectedLogistics(storeId);
    }

    @Override
    public List<String> getStoreSelectedLogisticsName(String storeId) {
        return storeLogisticsService.getStoreSelectedLogisticsName(storeId);
    }

    @Override
    public StoreLogistics add(String logisticsId, String storeId) {
        StoreLogisticsCustomerDTO storeLogisticsCustomerDTO = new StoreLogisticsCustomerDTO();
        storeLogisticsCustomerDTO.setLogisticsId(logisticsId);
        storeLogisticsCustomerDTO.setExtendId(storeId);
        return storeLogisticsService.add(storeLogisticsCustomerDTO);
    }

    @Override
    public boolean remove(StoreLogisticsParams storeLogisticsParams) {

        return storeLogisticsService.removeByParams(storeLogisticsParams);
    }
}
